package ca.cbc.msb.persistence;

import java.util.Date;

import org.springframework.transaction.annotation.Transactional;

import ca.cbc.medialib.dao.FailedMediaDAO;
import ca.cbc.medialib.entity.FailedMedia;
import ca.cbc.medialib.entity.Media;

public class FailedMediaPersistence {
	//private Logger logger = LoggerFactory.getLogger(this.getClass());
	private FailedMediaDAO failedMediaDAO;
	
	public FailedMediaDAO getFailedMediaDAO() {
		return failedMediaDAO;
	}
	
	public void setFailedMediaDAO(FailedMediaDAO failedMediaDAO) {
		this.failedMediaDAO = failedMediaDAO;
	}
	
	@Transactional
	public void save(Media media) {
		if(media == null) return;
		failedMediaDAO.save(new FailedMedia(media.getReleaseId(), media.getId(), media.getMobileId(),
                media.getTitle(), media.getReleaseUrl(), new Date()));
	}
}
